#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

typedef struct TreeNode *Tree;
struct TreeNode {
    int v;
    Tree Left, Right;
    int flag;//是否被访问过
};
Tree MakeTree(int N);
Tree NewNode(int input);
Tree Insert(Tree T, int input);
int check(Tree T, int input);
int Judge(Tree T, int N);
void ResetT(Tree T);
void FreeTree(Tree T);

int main()
{
    int N, L,i;
    Tree T;
    scanf("%d", &N);
    while(N)
    {
        scanf("%d", &L);
        T = MakeTree(N);
        for (i=0; i < L;i++)
        {
            if(Judge(T,N))
                printf("Yes\n");
            else
                printf("No\n");
            ResetT(T);//清空flag标志
        }
        FreeTree(T);//清空树重建
        scanf("%d", &N);
    }
    // printf("No\n");
    return 0;
}

Tree MakeTree(int N)
{
    int input,i;
    Tree T;
    scanf("%d", &input);
    T = NewNode(input);
    for (i = 1; i < N; i++)
    {
        scanf("%d", &input);
        T = Insert(T,input);
    }
    return T;

}

Tree NewNode(int input)
{
    Tree T = (Tree)malloc(sizeof(struct TreeNode));
    T->v = input;
    T->Left = T->Right = NULL;
    T->flag = 0;
    return T;
}

Tree Insert(Tree T, int input)
{
    if(!T)//空树
        T = NewNode(input);
    else
    {
        if(input>T->v)
            T->Right = Insert(T->Right, input);
        else
            T->Left = Insert(T->Left, input);
    }
    return T;
}
int check(Tree T, int input)
{
    if(T->flag)
    {
        if(input>T->v)
            return check(T->Right, input);
        else if(input<T->v)
            return check(T->Left, input);
        else
            return 0;
    }
    else
    {
        if(input == T->v)
        {
            T->flag = 1;
            return 1;
        }
        else
            return 0;
    }
}
int Judge(Tree T, int N)
{
    int input,i;
    int Is_Judge_done = 0;
    scanf("%d", &input);
    if(input!=T->v)
        Is_Judge_done = 1;
    else
        T->flag = 1;

    for (i= 1; i < N;i++)
    {
        scanf("%d", &input);
        if((!Is_Judge_done) && (!check(T,input)))
            Is_Judge_done = 1;
    }
    if(Is_Judge_done)
        return 0;
    else
        return 1;
}

void ResetT(Tree T)
{
    if(T->Left)
        ResetT(T->Left);
    if(T->Right)
        ResetT(T->Right);
    T->flag = 0;
}
void FreeTree(Tree T)
{
    if(T->Left)
        FreeTree(T->Left);
    if(T->Right)
        FreeTree(T->Right);
    free(T);
}